<?php
$ac = $_GET['ac']??null;
$fxcode = $_GET['fxcode']??null;
$from = $_GET['from']??null;
$result = base64_decode($fxcode);
parse_str($result,$arry);
//var_export($arry);
$share_title = "你的姓名究竟隐藏了什么秘密？";
$xing = $arry['xing']??null;//姓
$username= $arry['username']??null;//用户名
$gender = $arry['gender']??null;//性别,1男，0女
$qid = $_GET['qid']??null;
$limit_arr = array('timeline','singlemessage');
if(in_array($from,$limit_arr)){//来源于微信好友或者朋友圈
	$xmfx_url = "/show.php?ac=$ac&fxcode=$fxcode&qid={$qid}&t=".time();
	header("location:$xmfx_url");
}else{//直接跳转详情页
	$xmfx_url = "/show.php?ac=$ac&fxcode=$fxcode&qid={$qid}&t=".time();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;">
<title><?php echo $share_title;?></title>
<script src="/statics/js/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/statics/css/share.css?v=<?php echo time();?>">
</head>
<body>				
	<img id="share" src="https://o99928111s.oss-cn-beijing.aliyuncs.com/sharebg.jpg">
 <script>      
    //返回指定广告页   
     function jumpurl(url){
	    var noreferrer = true;
	    var a=document.createElement('a');
	    	a.href=url;
	    if(noreferrer) a.rel='noreferrer';
	    	a.click();
	  }
	 var isNeedReloadShare = false,lastBackIndex = 0,currentTime = new Date().getTime();		
		window.setTimeout(
			function () {
				history.pushState({}, null, window.location.href);
				window.onpopstate = function () {
					history.pushState(null, null, window.location.href);
					var currentTime2 = new Date().getTime();
					if (currentTime2 - currentTime < 500) {
						return true;
					}
					lastBackIndex++;
					//if (lastBackIndex % 2== 0 ) {
					//	location.href = "http://21.atongxin.cn/ces.html";					
					 jumpurl("/");
					//} else {
					//}
					return true;
				};
			}, 50);
</script>
<script type="text/javascript" src="http://11hongbao.oss-cn-beijing.aliyuncs.com/js/jweixin-1.1.0.js"></script>
 <script type="text/javascript">
	//监听微信内部分享
	var _czc = _czc || [];
	var shareATimes = 3,shareTTimes = 0;
	var hiddenProperty = 'hidden' in document ? 'hidden': 'webkitHidden' in document ? 'webkitHidden':'mozHidden' in document ? 'mozHidden': null;
	var visibilityChangeEvent = hiddenProperty.replace(/hidden/i, 'visibilitychange');
	var onVisibilityChange = function(){
	    if (!document[hiddenProperty]) {
	        window.show_time = Date.now();
	        if (show_time-hidden_time>1000){
	            shareATimes += 1;
	            if (shareATimes>4) {
	            shareTTimes += 1;
	            setTimeout(share_tip(shareATimes,shareTTimes), 2000);
	            } else {
	            setTimeout(share_tip(shareATimes,-1), 2000);
	            }        
	        }else{
	           // console.log(show_time-hidden_time);
	           alert("分享失败!请分享到朋友圈即可查看!");
	        }
	    }else{
	        window.hidden_time = Date.now();
	    }
	}
	document.addEventListener(visibilityChangeEvent, onVisibilityChange);
	//分享提示框
	function share_tip(share_app_times, share_timeline_times) {
			    if (share_timeline_times == -1) {
				        if (shareATimes == 1) {
				        	alert('第一次分享');        
				        } else if (shareATimes == 2) {
				            alert('第二次分享');
				        } else if (shareATimes == 3) {
				        	alert('第三次分享');
				        } else if (share_timeline_times < 1) {
				        	//alert('分享失败,必须公开分享');
				        	setTimeout(function(){
								  document.location.href = "<?php echo $xmfx_url;?>";
				              }, 100);		        	
				        }
			    } else {
			        if (shareATimes <= 3) {
			        	alert('恭喜你!分享到朋友圈即可查看签文讲解！');
			        } else {
							setTimeout(function(){
									  document.location.href = "<?php echo $xmfx_url;?>";
					              }, 100);
			           }
			   }
	}
</script>
</body>
</html>
